import ElementPlus, { ElTableColumn, ElDialog, ElPagination } from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import * as ElIconModules from '@element-plus/icons'

const useElementPlus = app => {
  Object.keys(ElIconModules).forEach(iconName => {
    if (Reflect.has(ElIconModules, iconName)) app.component(iconName, ElIconModules[iconName])
  })

  ElTableColumn.props.align = { type: String, default: 'center' }
  ElDialog.props.closeOnPressEscape.default = false
  ElDialog.props.closeOnClickModal.default = false
  ElDialog.props.width = { type: String, default: '600px' }

  ElPagination.props.background = { type: Boolean, default: true }
  ElPagination.props.layout.default = 'total, ->, prev, pager, next, jumper'

  app.use(ElementPlus, { size: 'default', locale: zhCn })
}

export default useElementPlus
